<?php
/**
 * This Helper Class helps hanlde File-Uploads as ajax and post-methods
 * 
 * AJAX-Methods are dificoult, couse if your entry is not even saved in 
 * the DB and you add files by AJAX, no one could know to wich ID the 
 * uploaded files schoudl be referenced
 *
 * In Postback Envoirment - what comes here????
 */
class UploadHandler {
	
	
	public function getUploadedFiles($ref = null) {
		
	}
	
}

/**
 * Represents an uploaded File
 *
 */
class UploadedFile {
	
	private $filename;
	private $type;
	private $tmpPath;
	private $size;
	
	private $path;
	private $isInTempUpld;
	
	public function getFilename() { return $this->filename; }
	public function getTmpPath() { return $this->tmpPath; }
	
	public function __construct($fileinfo) {
		
		if(is_array($fileinfo)) {
			$this->filename = $fileinfo["name"];
			$this->type = $fileinfo["type"];
			$this->tmpPath = $fileinfo["tmp_name"];	
			$this->size = $fileinfo["size"];	
			$this->isInTempUpld = true;
			
		}
	}
	
	public function copyTo($path) {
		
		if($this->isInTempUpld) {
			move_uploaded_file($this->tmpPath, $path);
		}
		else {
			copy($this->path, $path);
		}
	}
}

?>